package cn.zcscloud.mall.service.impl;

import cn.zcscloud.mall.mbg.mapper.SmsHomeRecommendSubjectMapper;
import cn.zcscloud.mall.mbg.mapper.UmsAdminLoginLogMapper;
import cn.zcscloud.mall.mbg.model.SmsHomeRecommendSubject;
import cn.zcscloud.mall.mbg.model.UmsAdminLoginLog;
import cn.zcscloud.mall.service.SmsHomeRecommendSubjectService;
import cn.zcscloud.mall.service.UmsAdminLoginLogService;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class SmsHomeRecommendSubjectServiceImpl extends ServiceImpl<SmsHomeRecommendSubjectMapper, SmsHomeRecommendSubject> implements SmsHomeRecommendSubjectService {
    @Autowired
    private SmsHomeRecommendSubjectMapper smsHomeRecommendSubjectMapper;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateRecommendStatus(List<Long> ids, Integer recommendStatus) {
        UpdateWrapper<SmsHomeRecommendSubject> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda().in(SmsHomeRecommendSubject::getRecommendStatus, ids);
        SmsHomeRecommendSubject recommendSubject = new SmsHomeRecommendSubject();
        recommendSubject.setRecommendStatus(recommendStatus);
        boolean update = this.update(recommendSubject,updateWrapper);
        return update ? 1 :0;
    }
}
